import 'package:flutter/material.dart';

class MyApp18 extends StatelessWidget {
  MyApp18({super.key});
  var data = [
    {
      "imgUrl":
          "https:\/\/smart-shop.itheima.net\/uploads\/10001\/20230320\/58a7c1f62df4cb1eb47fe83ff0e566e6.png",
      "imgName": "icon-1.png",
      "link": {
        "id": "c37c2ee",
        "title": "分类页",
        "type": "PAGE",
        "param": {
          "path": "pages\/category\/index",
          "url": "pages\/category\/index",
        },
      },
      "text": "新品首发",
    },
    {
      "imgUrl":
          "https:\/\/smart-shop.itheima.net\/uploads\/10001\/20230320\/49c64dbbf449e9e8abfca314f92814bd.png",
      "imgName": "icon-2.jpg",
      "link": {
        "id": "c37c2ee",
        "title": "分类页",
        "type": "PAGE",
        "param": {
          "path": "pages\/category\/index",
          "url": "pages\/category\/index",
        },
      },
      "text": "居家生活",
    },
    {
      "imgUrl":
          "https:\/\/smart-shop.itheima.net\/uploads\/10001\/20230320\/8573fbc5e87e8a88827e905fca284604.png",
      "imgName": "icon-1.png",
      "link": null,
      "text": "服饰鞋包",
    },
    {
      "imgUrl":
          "https:\/\/smart-shop.itheima.net\/uploads\/10001\/20230320\/f01c5fc360f55c6053beec34913bc699.png",
      "imgName": "icon-1.png",
      "link": null,
      "text": "美食酒水",
    },
    {
      "imgUrl":
          "https:\/\/smart-shop.itheima.net\/uploads\/10001\/20230320\/b106e9bd9e0c8c779e7d77a84e92ed93.png",
      "imgName": "icon-1.png",
      "link": null,
      "text": "个护清洁",
    },
    {
      "imgUrl":
          "https:\/\/smart-shop.itheima.net\/uploads\/10001\/20230320\/fd3a573889671b924d89859f521c30c9.png",
      "imgName": "icon-1.png",
      "link": null,
      "text": "母婴亲子",
    },
    {
      "imgUrl":
          "https:\/\/smart-shop.itheima.net\/uploads\/10001\/20230320\/8f979924a4fd3b5f406b62a6b405ea32.png",
      "imgName": "icon-1.png",
      "link": null,
      "text": "运动旅行",
    },
    {
      "imgUrl":
          "https:\/\/smart-shop.itheima.net\/uploads\/10001\/20230320\/f7657720f79ea9f769c40608f369130e.png",
      "imgName": "icon-1.png",
      "link": null,
      "text": "数码家电",
    },
    {
      "imgUrl":
          "https:\/\/smart-shop.itheima.net\/uploads\/10001\/20230320\/36f09e32efc53e1e695210ca92c54ed8.png",
      "imgName": "icon-1.png",
      "link": null,
      "text": "宠物生活",
    },
    {
      "imgUrl":
          "https:\/\/smart-shop.itheima.net\/uploads\/10001\/20230320\/0cccdb31952fbf3bc0026efbe260e40e.png",
      "imgName": "icon-1.png",
      "link": null,
      "text": "每日抄底",
    },
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(
          "GridView实战",
          style: TextStyle(
            color: Colors.white,
            fontWeight: FontWeight.bold,
            fontSize: 30,
          ),
        ),
        backgroundColor: Colors.red,
        centerTitle: true,
      ),
      body: GridView.builder(
        gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
          crossAxisCount: 5,
          childAspectRatio: 1,
          crossAxisSpacing: 10,
          mainAxisSpacing: 20,
        ),

        itemCount: data.length,
        itemBuilder: (context, index) => Card(
          child: Column(
            children: [
              Image.network(
                'https://yanxuan-item.nosdn.127.net/a09de222ed32efa8ffe359b1d5780574.jpg',
                width: 20,
                height: 20,
              ),
              Text(data[index]["text"].toString()),
            ],
          ),
        ),
      ),
    );
  }
}
